package com.hongyuan.venue.ui.person.activity;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayoutMediator;
import com.hongyuan.venue.R;
import com.hongyuan.venue.base.CustomActivity;
import com.hongyuan.venue.base.CustomFragment;
import com.hongyuan.venue.base.CustomViewModel;
import com.hongyuan.venue.databinding.ActivityMyOrdersBinding;
import com.hongyuan.venue.databinding.ActivityTrainingPayBinding;
import com.hongyuan.venue.databinding.ActivityTrainningOrdersBinding;
import com.hongyuan.venue.ui.Page2Adapter;
import com.hongyuan.venue.ui.person.fragment.MyOrdersFragment;
import com.hongyuan.venue.ui.person.fragment.TrainningOrdersFragment;

import java.util.ArrayList;
import java.util.List;

import me.tatarka.bindingcollectionadapter2.BR;

public class TrainOrdersActivity extends CustomActivity<ActivityTrainningOrdersBinding, CustomViewModel> {

    private List<CustomFragment> fragments;

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_trainning_orders;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initView() {
        super.initView();
        binding.comBack.setOnClickListener(view -> finish());

        //初始化数据
        fragments = new ArrayList<>();
        fragments.add(new TrainningOrdersFragment().setTabTag("全部").setPosition("0"));
        fragments.add(new TrainningOrdersFragment().setTabTag("待支付").setPosition("1"));
        fragments.add(new TrainningOrdersFragment().setTabTag("已支付").setPosition("2"));

        binding.mViewPager.setAdapter(new Page2Adapter(this,fragments));
        TabLayoutMediator tabLayoutMediator = new TabLayoutMediator(binding.tab, binding.mViewPager, (tab, position) -> {
            CustomFragment f = fragments.get(position);
            tab.setText(f.getTabTag());
        });
        tabLayoutMediator.attach();
    }
}
